package com.jpress.facade;

import java.util.List;

import com.jpress.control.AdminControl;
import com.jpress.control.BlogControl;
import com.jpress.control.CategoriaControl;
import com.jpress.control.ComentarioControl;
import com.jpress.control.CustomPageControl;
import com.jpress.control.PostControl;
import com.jpress.control.UsuarioControl;
import com.jpress.model.Admin;
import com.jpress.model.Blog;
import com.jpress.model.Categoria;
import com.jpress.model.Comentario;
import com.jpress.model.CustomPage;
import com.jpress.model.Post;
import com.jpress.model.Usuario;
import com.jpress.utils.General;

public class Facade {
	private General general;
	private AdminControl adminControl = new AdminControl();
	private BlogControl blogControl = new BlogControl();
	private CategoriaControl categoriaControl = new CategoriaControl();
	private ComentarioControl comentarioControl = new ComentarioControl();
	private CustomPageControl customPageControl = new CustomPageControl();
	private PostControl postControl = new PostControl();
	private UsuarioControl usuarioControl = new UsuarioControl();
	
	public Facade(){
		this.general = new General();
	}
	
	public boolean validarEmail(String string){
		return this.general.validarEmail(string);
	}
	
	public boolean verificarEmailCadastrado(String email){
		return this.adminControl.verificarEmailCadastrado(email);
	}
	
	public boolean verificarBlogCadastrado(String nomeBlog){
		return this.blogControl.verificarBlogCadastrado(nomeBlog);
	}
	
	public String geraHashMD5(String string){
		return this.general.md5(string);
	}
	
	public List<Blog> latestBlogs() {
		return blogControl.getUltimosBlogs();
	}

	public int getBlogsQtde() {
		return blogControl.getBlogQtde();
		
	}

	public int getAdminsQtde() {
		return adminControl.getAdminQtde();
	}

	public int getUsuariosQtde() {
		return usuarioControl.getUsuarioQtde();
	}

	public int getPostsQtde() {
		return postControl.getPostQtde();
	}

	public int getComentariosQtde() {
		return comentarioControl.getComentarioQtde();
	}

	public List<Post> getUltimosPostsByEmail(String email) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Comentario> getUltimosComentariosByEmail(String email) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Blog> getMeusBlogsByEmail(String email) {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean cadastrarAdmin(Admin novoAdmin) {
		return adminControl.cadastrarAdmin(novoAdmin);
	}

	public boolean cadastrarPost(Post novoPost, int idAdmin, int idBlog) {
		return postControl.cadastrarPost(novoPost, idAdmin, idBlog);
	}
	
	public Usuario efetuarLogin(String email, String senha){
		return usuarioControl.efetuarLogin(email, senha);
	}

/*	public boolean cadastrarBlog(Blog novoBlog) {
		return blogControl.cadastrarBlog(novoBlog);
	}
*/	
	public boolean cadastrarBlog(Blog novoBlog, int dono) {
		return blogControl.cadastrarBlog(novoBlog, dono);
	}	

	public boolean cadastrarCategoria(Categoria novaCategoria) {
		return categoriaControl.cadastrarCategoria(novaCategoria);
	}
	
	public boolean cadastrarCustomPage(CustomPage novaCustomPage) {
		return customPageControl.cadastrarCustomPage(novaCustomPage);
	}

	public List<Blog> meusBlogs(int id) {
		return blogControl.meusBlogs(id);
	}

	public List<Post> meusPosts(int id) {
		return postControl.meusPosts(id);
	}

	public List<Comentario> meusComentarios(int id) {
		return comentarioControl.meusComentarios(id);
	}

	public boolean atualizarAdmin(Admin adminAtual) {
		return adminControl.atualizarAdmin(adminAtual);
	}
	
	public String paginaOrigem(String string){
		return general.paginaOrigem(string);	
	}
	
	public Blog getBlogById(int id){
		return blogControl.getBlogById(id);
	}
	
	public Post getPostById(int id){
		return postControl.getPostById(id);
	}
	
	public Comentario getComentarioById(int id){
		return comentarioControl.getComentarioById(id);
	}

	public void excluirBlog(Blog blog) {
		blogControl.excluirBlog(blog);
	}

	public boolean atualizarBlog(Blog blog) {
		return blogControl.atualizarBlog(blog);
	}

	public void excluirPost(Post post) {
		postControl.excluirPost(post);
	}

	public boolean atualizarPost(Post postAtual) {
		return postControl.atualizarPost(postAtual);
	}

	public List<Categoria> getCategoriasByIdBlog(int blogId) {
		return categoriaControl.getCategoriasByIdBlog(blogId);
	}

	public CustomPage getCustomPageById(int id) {
		return customPageControl.getCustomPageById(id);
	}

	public void excluirCustomPage(CustomPage custompage) {
		customPageControl.excluirCustomPage(custompage);
	}

	public boolean atualizarCustomPage(CustomPage customPageAtual) {
		return customPageControl.atualizarCustomPage(customPageAtual);
	}

	public boolean cadastrarCustomPage(CustomPage customPageNova, int idBlog) {
		return customPageControl.cadastrarCustomPage(customPageNova, idBlog);
	}

	public List<Post> getPostsByBlogId(int id) {
		return postControl.getPostsByBlogId(id);
	}

	public List<CustomPage> getCustomPageByBlogId(int id) {
		return customPageControl.getCustomPageByBlogId(id);
	}

	public boolean cadastrarUsuario(Usuario novoUsuario) {
		return usuarioControl.cadastrarUsuario(novoUsuario);
	}

	public boolean atualizarUsuario(Usuario usuarioAtual) {
		return usuarioControl.atualizarUsuario(usuarioAtual);
	}

	public List<Comentario> getComentariosByPostId(int id) {
		return comentarioControl.getComentariosByBlogId(id);
	}

	public boolean cadastrarComentario(Comentario novoComentario, int id, int idpost) {
		return comentarioControl.cadastrarComentario(novoComentario, id, idpost);
	}
}
